<?php
/**
 * Created by PhpStorm.
 * User: July
 * Date: 2019/3/6
 * Time: 15:37
 * 投放卡券
 * 创建二维码
 */

require_once('common.php');

//创建二维码地址
$qrCodeUrl = 'https://api.weixin.qq.com/card/qrcode/create?access_token=';

//获取access_token
$access_token = get_access_token();

$data = $_GET;
$card_id = trim($data['card_id']);

$data = array(
    'action_name' => 'QR_CARD',
    'expire_seconds' => 1800,
    'action_info' => array(
        'card' => array(
            'card_id' => $card_id,
            'code' => '',
            'openid' => '',
            'is_unique_code' => false,
            'outer_id' => ''
        )
    )
);

$result = jsonpostJson($qrCodeUrl . $access_token, $data, true);

$ticketUrl = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=';
$ticket = $result['ticket'];
$qrCode = $ticketUrl . urlencode($ticket);

print_r($qrCode);

die();